﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace X9Tech.HashWall.Core
{
    public class HashWallContext
    {
        private static HashWallContext curContext = null;
        public static HashWallContext Current
        {
            get
            {
                if (curContext == null)
                {
                    curContext = new HashWallContext();
                }

                return curContext;
            }
        }

        private HashWallContext()
        {
            msgMgr = new Messaging.MessagingManager(this);
            bgOps = new Operations.BackgroundOperationsManager(this);
        }

        public void LoadHashtagStream(string hashtags)
        {
            List<string> tags = hashtags.Split(";".ToCharArray()).ToList();

            this.WallStreams.Clear();

            foreach (string tag in tags)
            {
                this.WallStreams.Add(new Stream.WallStream(tag.Trim()));
            }
        }

        public List<string> ActiveStreamTagNames
        {
            get
            {
                List<string> tagList = new List<string>();

                foreach (Stream.WallStream stream in this.WallStreams)
                {
                    tagList.Add(stream.HashTagSearchTerm);
                }

                return tagList;
            }
        }

        private List<Stream.WallStream> wallStreamList = new List<Stream.WallStream>();
        public List<Stream.WallStream> WallStreams { get { return wallStreamList; } }

        private Messaging.MessagingManager msgMgr = null;
        private Operations.BackgroundOperationsManager bgOps = null;

        public Messaging.MessagingManager Messaging { get { return msgMgr; } }
        public Operations.BackgroundOperationsManager BackgroundOperations { get { return bgOps; } }


    }
}
